<?php
defined('ANT_ACCESS') or die('Access denided');
/**
 * Ant Framework
 *
 * An open source application development framework for PHP 5
 *
 * @package		Ant Framework
 * @author		Meshin Dmitriy
 * @copyright	Copyright (c) 2008, Meshin Dmitriy
 * @license		GNU Public Lisence v2
 * @link		http://code.google.com/p/ant-framework
 * @desc		Benchmark class
 **/
	class ANT_benchmark{
		protected $points = array();

		/*
		 *	Устанавливает метку
		 * */
		public function point($point){
			if(!isset($this->points[$point])){
				$this->points[$point] = microtime(TRUE);
			}
		}

		/*
		 *	Возвращает время работы
		 * */
		public function get_time($start, $end = ''){
			if(isset($this->points[$start])){
				$end = (($end == '' || !isset($this->points[$end])) ? microtime(TRUE) : $this->points[$end]);				return sprintf("%001.3f", ($end - $this->points[$start]));
			}
		}

		/*
		 *	Возвращает количество занятой памяти
		 * */
		public function memory_usage(){
			return (sprintf("%001.3f", (memory_get_usage() / (1024*1024))));
		}
	}
?>